package effect;

import card.CreatureCard;
import core.MapUtil;

/**
 * 
 * @author Oscar
 *
 */
public class AsraiDance extends Effect {
	public AsraiDance(){
		name="Asrai Dance";
		description="The Asrai dance invokes bloodthirst and rage in all creatures in this land, increasing their max damage by 1 for 2 turns.";
		imageName="cardIconAsraiDance.png";
		effectTypes.add(EffectType.activatable);
		targetType = TargetType.none;
		manaCost=6;
	}
	
	@Override
	public void activate(){
		EffectUtil.getCard(this).getOwner().addMana(-6);
		
		CreatureCard temp = (CreatureCard) EffectUtil.getCard(this);
		for(CreatureCard c : MapUtil.getTileOfCard(temp).getCreatures())
			if(hasAsraiRage(c)== false)
				c.addEffect(EffectGenerator.generateEffect("AsraiRage"));
			else
				resetTimer(c);
		System.out.println("Asrai Dance");
	}
	
	@Override
	public boolean canActivate(){
		if(EffectUtil.getCard(this).getOwner().getMana()>=6)
			return true;
		else
			return false;
	}
	
	private boolean hasAsraiRage(CreatureCard c){
		for(Effect e : c.getEffects())
			if(e instanceof AsraiRage)
				return true;
		return false;
	}
	
	private void resetTimer(CreatureCard c){
		for(Effect e : c.getEffects())
			if(e instanceof AsraiRage)
				((AsraiRage) e).setTurnsLeft(2);
	}
}
